Expose provider token usage on responses - #151
Conversation
|
Background: Tracking LLM cost on a per-user or per-task basis. |
|
@mattt Does this make sense to you? |
|
this would be great to have |
|
@KotlinFactory any plans to support MLXLanguageModel also? |
|
@noorbhatia Sure why not. But lets focus on getting this merged first. |
Parses vLLM/OpenRouter chat-completions reasoning fields (reasoning_content, reasoning) and Responses API reasoning output items (reasoning_text / summary_text parts) into a new optional LanguageModelSession.Response.reasoning. Reasoning fields are decode-only and never re-encoded into upstream messages. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Hi @KotlinFactory. Yes, this makes sense, and I'm sorry for leaving your question unanswered. Would you rebase onto |
|
One more thing while you're rebasing: Apple added usage reporting to Foundation Models in iOS/macOS 27 as Could you shape this PR's type to match that (name and structure) rather than a separate |
Summary
LanguageModelUsagetype for provider-reported token usageLanguageModelSession.Responseand streaming snapshotsTesting
xcrun swift buildxcrun swift test --filter MockLanguageModelTestsNotes
huggingface/main